home *** CD-ROM | disk | FTP | other *** search
/ LiquidLibrary 2005 February / LiquidLibrary 2005 February - Disc 1.iso / pc / Portfolio Browser / Filters / PDF / LIB / gs_dps1.ps < prev    next >
Text File  |  2003-01-03  |  4KB  |  132 lines

  1. %    Copyright (C) 1997, 1999 Aladdin Enterprises.  All rights reserved.
  2. % This software is licensed to a single customer by Artifex Software Inc.
  3. % under the terms of a specific OEM agreement.
  4.  
  5. % $RCSfile$ $Revision$
  6. % Initialization file for most of the Display PostScript functions
  7. % that are also included in Level 2.
  8.  
  9. level2dict begin
  10.  
  11. % ------ Virtual memory ------ %
  12.  
  13. /currentshared /.currentglobal load def
  14. /scheck /.gcheck load def
  15. %****** FOLLOWING IS WRONG ******
  16. /shareddict currentdict /globaldict .knownget not { 20 dict } if def
  17.  
  18. % Global and LocalFontDirectory must remain in systemdict
  19. % even if we temporarily exit Level 2 mode.
  20.  
  21. end                % level2dict
  22. systemdict begin
  23.  
  24. /SharedFontDirectory .FontDirectory .gcheck
  25.  { .currentglobal false .setglobal
  26.    /LocalFontDirectory .FontDirectory dup maxlength dict copy
  27.    .forcedef    % LocalFontDirectory is local, systemdict is global
  28.    .setglobal .FontDirectory
  29.  }
  30.  { /LocalFontDirectory .FontDirectory
  31.    .forcedef    % LocalFontDirectory is local, systemdict is global
  32.    50 dict
  33.  }
  34. ifelse def
  35.  
  36. end                % systemdict
  37. level2dict begin
  38.  
  39. % setshared must rebind FontDirectory to the appropriate one of
  40. % Local or SharedFontDirectory.
  41.  
  42. /.setglobal        % <bool> .setglobal -
  43.  { dup .setglobal
  44.    //systemdict /FontDirectory .currentglobal
  45.     { //SharedFontDirectory }
  46.     { /LocalFontDirectory .systemvar }    % can't embed ref to local VM
  47.    ifelse .forceput pop    % LocalFontDirectory is local, systemdict is global
  48.  } .bind odef        % must bind .forceput and .setglobal
  49.             % even if NOBIND in effect
  50. % Don't just copy (load) the definition of .setglobal:
  51. % it gets redefined for LL3.
  52. /setshared { /.setglobal .systemvar exec } odef
  53. .currentglobal setshared
  54.  
  55. % See below for changes in save and restore.
  56.  
  57. % ------ Fonts ------ %
  58.  
  59. /selectfont        % <fontname> <size> selectfont -
  60.  { 1 index findfont
  61.    1 index dup type /arraytype eq { makefont } { scalefont } ifelse
  62.    setfont pop pop
  63.  } odef
  64. % undefinefont has to take local/global VM into account.
  65. /undefinefont        % <fontname> undefinefont -
  66.  { .FontDirectory 1 index .undef
  67.    .currentglobal
  68.     {        % Current mode is global; delete from local directory too.
  69.       //systemdict /LocalFontDirectory .knownget
  70.        { 1 index .undef }
  71.       if
  72.     }
  73.     {        % Current mode is local; if there was a shadowed global
  74.         % definition, copy it into the local directory.
  75.       //systemdict /SharedFontDirectory .knownget
  76.        { 1 index .knownget
  77.       { .FontDirectory 2 index 3 -1 roll put }
  78.      if
  79.        }
  80.       if
  81.     }
  82.    ifelse pop
  83.  } odef
  84.  
  85. % If we load a font into global VM within an inner save, the restore
  86. % will delete it from FontDirectory but not from SharedFontDirectory.
  87. % We have to handle this by making restore copy missing entries from
  88. % SharedFontDirectory to FontDirectory.  Since this could slow down restore
  89. % considerably, we define a new operator .dictcopynew for this purpose.
  90. % Furthermore, if FAKEFONTS is in effect, we want global real fonts to
  91. % override fake local ones.  We handle this by brute force.
  92. /restore        % <save> restore -
  93.  { dup //restore    % bind even if NOBIND
  94.    /LocalFontDirectory .systemvar
  95.    FAKEFONTS
  96.     { mark
  97.         % We want to delete a fake font from the local directory
  98.         % iff the global directory now has no definition for it,
  99.         % or a non-fake definition.
  100.       1 index dup
  101.        {        % Stack: lfd mark lfd key ... lfd key value
  102.      length 1 gt
  103.       {        % This is a real local definition; don't do anything.
  104.         pop
  105.       }
  106.       {        % This is a fake local definition, check for global.
  107.         //SharedFontDirectory 1 index .knownget
  108.          {        % A global definition exists, check for fake.
  109.            length 1 eq { pop } { 1 index } ifelse
  110.          }
  111.          {        % No global definition, delete the local one.
  112.            1 index
  113.          }
  114.         ifelse
  115.       }
  116.      ifelse
  117.        } forall
  118.       pop counttomark 2 idiv { .undef } repeat pop
  119.     }
  120.    if
  121.    //SharedFontDirectory exch .dictcopynew pop
  122.    .currentglobal .setglobal    % Rebind FontDirectory according to current VM.
  123.    pop
  124.  } bind odef
  125.  
  126. % ------ Miscellaneous ------ %
  127.  
  128. /undef /.undef load def
  129.  
  130. end                % level2dict
  131.